package com.xiaoshuidi.cloud.module.report.constant;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 出租状态枚举
 *
 * @author hans.zhang
 */
@Getter
@AllArgsConstructor
public enum RentStatusEnum {
    EMPTY("1", "空置"),
    SCHEDULED("2", "已预定"),
    CHECKEDIN("3", "已租"),
    STAYINGIN("4", "已租"),
    MAINTENANCE("6", "维修"),
    FREEZE("5", "停用"),
    ;

    private String value;
    private String name;

    public static String getValueByName(String name) {
        RentStatusEnum rentStatusEnum = Arrays.stream(RentStatusEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(rentStatusEnum != null, "RentStatusEnum类型:{}不存在", name);
        return rentStatusEnum.getValue();
    }

    public static String getName(String value) {
        RentStatusEnum first = Arrays.stream(RentStatusEnum.values()).filter(s -> value.equals(s.getValue())).findFirst().orElse(null);
        if (first == null) {
            return "";
        }
        return first.getName();
    }

}
